<!DOCTYPE html>
<html>
<head>
    <title>文件上传和预览</title>
</head>
<body>
    <input type="file" id="fileInput" >
    <div id="preview"></div>

    <script>
        const fileInput = document.getElementById('fileInput');
        const preview = document.getElementById('preview');

        fileInput.addEventListener('change', function() {
          console.log(fileInput,'fileInput');
          
            const file = fileInput.files[0];
            const reader = new FileReader();

            reader.onload = function(e) {
                const pdfUrl = e.target.result;
                preview.innerHTML = `<embed src="${pdfUrl}" width="800" height="600" type='application/pdf'>`;
            }

            reader.readAsDataURL(file);
        });
    </script>
</body>
</html>
